-- 导入响应式api
local r = require "ch7.r"

local reactive = r.reactive
local ref = r.ref
local effect = r.effect

print("rApi", reactive, ref, effect)


local function createRenderer()
    local function patch(n1, n2, container)

    end

    local function render(vnode, container)
        if (vnode) then
            -- 挂载新的 比较
            patch(container._vnode, vnode, container)
        else
            -- 卸载旧的
            if (container._vnode) then
                container["content"] = ""
            end
        end
        -- 记录旧的
        container._vnode = vnode
        print("container",container._vnode)
    end

    return {
        render = render
    }
end

local renderer = createRenderer();

local count = ref(1)

effect(function()
    renderer.render("<h1>" .. count.value .. "</h1>", {})
end)

count.value = 2;
